﻿#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;A_Is64BitOs 当操作系统为 64 位则值为 1(真), 为 32 位则为 0(假). 
SplitPath A_ScriptFullPath, null, IniDir, null, IniFile, null
global IniFile
IniFile = %A_ScriptDir%\%IniFile%.ini
IfNotExist %IniFile% ;检测ini文件是否与APP同名
{
    MsgBox 未找到配置 %IniFile%. 
    ExitApp
}

Loop, %1% ;接受文件参数
{
    act := %A_Index%
    strFileName := act
    if (strFileName != 0)
    {
        Goto Funsub
    } else {
        Goto Defsub
    }
    ExitApp
}

Defsub: ;不带参数运行
    If %A_Is64BitOs%
    {
        IniRead Program, %IniFile%, X64, Soft
        strFileName := Program
        If FileExist(strFileName)
        {
            Run %Program%
        } Else {
            MsgBox 未找到应用程序
        }
    } Else {
        IniRead Program,%IniFile%, X86, Soft
        strFileName := Program
        If FileExist(strFileName)
        {
            Run %Program%
        } Else {
            MsgBox 未找到应用程序
        }
    }
return

Funsub: ;带参数运行
    If %A_Is64BitOs%
    {
        IniRead Program, %IniFile%, X64, Soft
        strFileName := Program
        If FileExist(strFileName)
        {
            Run %Program% %act%
        } Else {
            MsgBox 未找到应用程序
        }
    } Else {
        IniRead Program,%IniFile%, X86, Soft
        strFileName := Program
        If FileExist(strFileName)
        {
            Run %Program% %act%
        } Else {
            MsgBox 未找到应用程序
        }
    }
return
